//
//  RelationTableViewCell.m
//  绿地管理系统
//
//  Created by rimi on 16/1/28.
//  Copyright © 2016年 hexs. All rights reserved.
//

#import "RelationTableViewCell.h"
#import "XSPullDownControl.h"

@interface RelationTableViewCell ()

@property (nonatomic, strong) UIImageView *photoView;
@property (nonatomic, strong) UITextField *nameRemarkTextField;
@property (nonatomic, strong) UITextField *remarkTextField;
@property (nonatomic, strong) XSPullDownControl *pullDownControl;

@end

@implementation RelationTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initializeAppearance];
    }
    return self;
}

- (void)initializeAppearance
{
    [self.contentView addSubview:self.photoView];
    [self.contentView addSubview:self.nameRemarkTextField];
    [self.contentView addSubview:self.remarkTextField];
    [self.contentView addSubview:self.pullDownControl];
    
    
    NSArray *textArray = @[@"关系类型：",@"名字备注：",@"亲密程度：",@"重要程度：",@"备注信息："];
    for (int i = 0; i < 5; ++i) {
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(30, 85 + i*(18+18), 100, 18)];
        label.text = textArray[i];
        label.font = [UIFont systemFontOfSize:18];
        label.textColor = [UIColor darkTextColor];
        [self.contentView addSubview:label];
    }
    
}

#pragma mark -- getter

- (UIImageView *)photoView
{
    if (_photoView == nil) {
        
    }
    return _photoView;
}

- (UITextField *)nameRemarkTextField
{
    if (_nameRemarkTextField == nil) {
        
    }
    return _nameRemarkTextField;
}
- (UITextField *)remarkTextField
{
    if (_remarkTextField == nil) {
        
    }
    return _remarkTextField;
}

- (XSPullDownControl *)pullDownControl
{
    if (_pullDownControl == nil) {
        NSArray *options = @[@"朋友",@"客户",@"同事",@"其他"];
        _pullDownControl = [[XSPullDownControl alloc] initWithFrame:CGRectMake(115, 80, 120, 30) optionsList:options];
        _pullDownControl.backgroundColor = [UIColor whiteColor];
        
        __weak typeof(self) weakSelf = self;
        _pullDownControl.clickAction = ^(XSPullDownControl *pullDownControl) {
            if (weakSelf.delegate && [weakSelf.delegate respondsToSelector:@selector(relationCellDidSelectRelation:)]) {
                [weakSelf.delegate relationCellDidSelectRelation:weakSelf];
            }
        };
    }
    return _pullDownControl;
}

- (NSInteger)relation
{
    return self.pullDownControl.selectedIndex;
}
@end

















